package com.boy.commonutils.handler;

import com.boy.tool.domain.ResultVo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Create with IntelliJ IDEA.
 *
 * @Auther：Whd
 * @Date：2022-10-26-19:38
 * @Description；
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultVo error(Exception e) {
        e.printStackTrace();
        return ResultVo.failure();
    }

    @ExceptionHandler(WhdException.class)
    @ResponseBody
    public ResultVo error(WhdException e) {
        e.printStackTrace();
        return ResultVo.failure(e.getCode(), e.getMsg());
    }


}
